#ifndef MAINUI_H
#define MAINUI_H

#include <QWidget>
#include <QtGui/QMainWindow>
#include <QStackedWidget>
#include <QStatusBar>
#include <QMenuBar>
#include <QAction>
#include <QSocketNotifier>


#include "global.h"
#include "mainwindow.h"
#include "simplemainwindow.h"
#include "graphicitemsettingdialog.h"
#include "keyWordSearch.h"
#include "regionSearch.h"
#include "typeSearch.h"

#include "myuart.h"
#include "serialframe.h"
#include "msgproc.h"

class MainUI : public QWidget
{
    Q_OBJECT
public:
    explicit MainUI(QWidget *parent = 0);

private:
    void create_actions();
    void create_status_bar();
    void init_node_status();

signals:
    void sig_next();    //下一页 信号
    void sig_previous();//上一页 信号
    void sig_init_show();
    // 串口中的数据构成了应用层数据帧，通知应用层消息处理类MsgProc
    void sig_aplDataComing();


public slots:
   void  change_mode();

private slots:
   void import_config();
   void export_config();
   void set_graphic_item();
   void set_permition();
   void update_status_bar();
   void next_clicked();
   void previous_clicked();
   void keyWordSearch();
   void regionSearch();
   void typeSearch();
   void order_to_send(int btn_number);
   // 串口有原始数据到来
   void uartDataCame();
   void slot_send_frame(QByteArray msg);

private:
   QStackedWidget *widgetStack;
   MainWindow *FullModeWindow;
   SimpleMainWindow *SimpleModeWindow;
   //手控点设置界面
   GraphicItemSettingDialog *gra_item_setting_dlg;
   KeyWordSearch *keyWordSearchWindow;
   RegionSearch *regionSearchWindow;
   TypeSearch *typeSearchWindow;

   MyUart *dev_serial;  //  串口设备类
   SerialFrame *app_data_frame; // 串口数据帧封装和解封
   MsgProc *msg_processor;  //  应用层消息处理器
   QSocketNotifier *uart_notifier;  // 串口数据监听器

   //菜单栏与状态栏
   QStatusBar *status_bar;
   QMenuBar *menu_bar;

   //文件菜单－action
   QAction *import_config_act;
   QAction *export_config_act;
   QAction *mode_change;
   QAction *exit_act;

   //设置菜单－action
   QAction *set_graphic_item_act;
   QAction *set_permition_act;

   //查询菜单－action
   QAction *keyword_search_act;
   QAction *region_search_act;
   QAction *type_search_act;

   QPushButton *next_page;
   QPushButton *previous_page;
};

#endif // MAINUI_H
